"""
需要导入第三方模块
cmd控制台输入以下命令并执行：
pip install langchain_openai
"""
from langchain_openai import ChatOpenAI
from langchain_core.output_parsers import StrOutputParser
output_parser = StrOutputParser()
chatLLM = ChatOpenAI(
    # 需要在阿里云百炼中申请apikey
    # https://bailian.console.aliyun.com
    api_key="sk-ff09439b27cd46aabfe7a6e2a698fc53",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    model="qwen-max",
)
while True:
    message = input("用户>>>")
    chain = chatLLM | output_parser
    print("AI>>>" + chain.invoke(message))